import request from "@/utils/request";

export const userRegisterAPI = (registerData) => {
  const params = new URLSearchParams();
  for (const key in registerData) {
    params.append(key, registerData[key]);
  }
  return request.post('/user/register', params);
};

export const userLoginAPI = (loginData) => {
  const params = new URLSearchParams();
  for (const key in loginData) {
    params.append(key, loginData[key]);
  }
  return request.post('/user/login', params);
};

export const getUserInfoAPI = () => {
  return request.get('/user/info');
};

export const updateUserInfoAPI = (userInfo) => {
  return request.put('/user/update', userInfo);
};

export const updateUserAvatarAPI = (avatarUrl) => {
  return request.patch(`/user/avatar?avatarUrl=${avatarUrl}`);
};

export const updateUserPasswordAPI = (params) => {
  return request.patch('/user/password', params);
};